#!/bin/sh
namespace=${PLUGIN_NAMESPACE}
container1=${PLUGIN_CONTAINER1}
container2=${PLUGIN_CONTAINER2}
images1=${PLUGIN_IMAGE1}
images2=${PLUGIN_IMAGE2}
deployment=${PLUGIN_DEPLOYMENT}

if [ -z ${namespace} ]
then
  namespace="default"
fi

if [ -z ${deployment} ]
then
  echo "the deployment is required"
  exit
fi

if [ -z ${images1} ]
then
  echo "the image1 is required"
  exit
fi

if [ -z ${container1} ]
then
  echo "the container1 is required"
  exit
fi

if [ -z ${images2} ]
then
  kubectl set image deployment/${deployment} -n ${namespace} ${container1}=${images1}
else
  kubectl set image deployment/${deployment} -n ${namespace} ${container1}=${images1} ${container2}=${images2}
fi
